package com.NetSunWeiQin.chapter03.multithread2;

public class ThreadPoolTester {


    public static void main(String[] args) {

        int numTasks = 10;
        int poolSize = 4;

        ThreadPool threadPool = new ThreadPool(poolSize);


        for (int i = 0; i < numTasks; i++) {
            threadPool.execute(createTask(i));
        }


        threadPool.join();

    }

    private static Runnable createTask(final int taskID) {
        return new Runnable() {
            public void run() {
                System.out.println("Task " + taskID + ": start");
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException ex) {
                }
                System.out.println("Task " + taskID + ": end");
            }
        };
    }
}


